// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.core.components;

import org.dengues.core.process.ICompNode;
import org.dengues.core.property.EParameterFieldCategory;
import org.dengues.core.property.EPropertyCategory;
import org.dengues.model.database.AbstractDBObject;

public class NodePropertyParameter implements Cloneable {

	private String[] itemNames;

	private Object[] itemValues;

	private String itemDefault;

	private boolean isRequired;

	private boolean isReadOnly;

	private int nbLines;

	private String repositoryValue;

	private String context;

	private final ICompNode node;

	private String name;

	private String field;

	private boolean isShow;

	private int nbRow;

	private String displayName;

	private EPropertyCategory propertyCategory;

	private EParameterFieldCategory fieldCategory;

	private final AbstractDBObject abstractDBObject;

	private Object value;

	public NodePropertyParameter(ICompNode node) {
		this.node = node;
		this.abstractDBObject = null;
	}

	public NodePropertyParameter(AbstractDBObject child) {
		this.abstractDBObject = child;
		this.node = null;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getField() {
		return field;
	}

	public void setField(String field) {
		this.field = field;
	}

	public boolean isShow() {
		return isShow;
	}

	public void setShow(boolean isShow) {
		this.isShow = isShow;
	}

	public int getNbRow() {
		return nbRow;
	}

	public void setNbRow(int nbRow) {
		this.nbRow = nbRow;
	}

	public EParameterFieldCategory getFieldCategory() {
		return fieldCategory;
	}

	public void setFieldCategory(EParameterFieldCategory fieldCategory) {
		this.fieldCategory = fieldCategory;
	}

	public EPropertyCategory getPropertyCategory() {
		return propertyCategory;
	}

	public void setPropertyCategory(EPropertyCategory propertyCategory) {
		this.propertyCategory = propertyCategory;
	}

	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	/**
	 * Getter for node.
	 * 
	 * @return the node
	 */
	public ICompNode getNode() {
		return this.node;
	}

	/**
	 * Getter for isRequired.
	 * 
	 * @return the isRequired
	 */
	public boolean isRequired() {
		return this.isRequired;
	}

	/**
	 * Sets the isRequired.
	 * 
	 * @param isRequired
	 *            the isRequired to set
	 */
	public void setRequired(boolean isRequired) {
		this.isRequired = isRequired;
	}

	/**
	 * Getter for isReadOnly.
	 * 
	 * @return the isReadOnly
	 */
	public boolean isReadOnly() {
		return this.isReadOnly;
	}

	/**
	 * Sets the isReadOnly.
	 * 
	 * @param isReadOnly
	 *            the isReadOnly to set
	 */
	public void setReadOnly(boolean isReadOnly) {
		this.isReadOnly = isReadOnly;
	}

	/**
	 * Getter for nbLines.
	 * 
	 * @return the nbLines
	 */
	public int getNbLines() {
		return this.nbLines;
	}

	/**
	 * Sets the nbLines.
	 * 
	 * @param nbLines
	 *            the nbLines to set
	 */
	public void setNbLines(int nbLines) {
		this.nbLines = nbLines;
	}

	/**
	 * Getter for repositoryValue.
	 * 
	 * @return the repositoryValue
	 */
	public String getRepositoryValue() {
		return this.repositoryValue;
	}

	/**
	 * Sets the repositoryValue.
	 * 
	 * @param repositoryValue
	 *            the repositoryValue to set
	 */
	public void setRepositoryValue(String repositoryValue) {
		this.repositoryValue = repositoryValue;
	}

	/**
	 * Getter for context.
	 * 
	 * @return the context
	 */
	public String getContext() {
		return this.context;
	}

	/**
	 * Sets the context.
	 * 
	 * @param context
	 *            the context to set
	 */
	public void setContext(String context) {
		this.context = context;
	}

	/**
	 * Getter for itemDefault.
	 * 
	 * @return the itemDefault
	 */
	public String getItemDefault() {
		return this.itemDefault;
	}

	/**
	 * Sets the itemDefault.
	 * 
	 * @param itemDefault
	 *            the itemDefault to set
	 */
	public void setItemDefault(String itemDefault) {
		this.itemDefault = itemDefault;
	}

	/**
	 * Getter for itemValues.
	 * 
	 * @return the itemValues
	 */
	public Object[] getItemValues() {
		return this.itemValues;
	}

	/**
	 * Sets the itemValues.
	 * 
	 * @param itemValues
	 *            the itemValues to set
	 */
	public void setItemValues(Object[] itemValues) {
		this.itemValues = itemValues;
	}

	/**
	 * Getter for itemNames.
	 * 
	 * @return the itemNames
	 */
	public String[] getItemNames() {
		return this.itemNames;
	}

	/**
	 * Sets the itemNames.
	 * 
	 * @param itemNames
	 *            the itemNames to set
	 */
	public void setItemNames(String[] itemNames) {
		this.itemNames = itemNames;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#clone()
	 */
	@Override
	public NodePropertyParameter clone() {
		NodePropertyParameter parameter = null;
		try {
			parameter = (NodePropertyParameter) super.clone();
			if (getItemNames() != null) {
				parameter.setItemNames(getItemNames().clone());
			}
			if (getItemValues() != null) {
				parameter.setItemValues(getItemValues().clone());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return parameter;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuffer s = new StringBuffer();
		s.append("Name: " + getName() + "->"); //$NON-NLS-1$ //$NON-NLS-2$
		s.append("Value" + getValue() == null ? "" : getValue().toString()); //$NON-NLS-1$ //$NON-NLS-2$
		return s.toString();
	}

	public AbstractDBObject getAbstractDBObject() {
		return abstractDBObject;
	}

}
